// --------------------------------------------------------------------------------------------------------------------
// <copyright file="DeviceTest.cs" company="Microsoft Corporation">
// The MIT License (MIT)
// 
// Copyright (c) 2014, Microsoft Corporation
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to deal
//  in the Software without restriction, including without limitation the rights
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace Microsoft.Robotics.Hardware.EV4.UnitTests
{
    using Microsoft.Robotics.Hardware.DAC;
    using Microsoft.Robotics.Numerics;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    /// <summary>
    /// Tests DeviceConfiguration
    /// </summary>
    [TestClass]
    public class DeviceTest
    {
        /// <summary>
        /// Tests ability for a DAC.DeviceState to be generate with cached device configuration info
        /// </summary>
        [Priority(0)]
        [TestMethod]
        [TestCategory("Unit")]
        public void TestAccelerometer()
        {
            string comment = "Foo";
            int deviceId = 1;
            DeviceType deviceType = DeviceType.Accelerometer;
            string model = "Faa";
            Vector3 posePosition = new Vector3(1, 2, 3);
            Quaternion poseOrientation = new Quaternion(4, 5, 6, 1.2345);
            Pose pose = new Pose(posePosition, poseOrientation);
            long nativeDeviceTimestamp = 1234;
            Vector3 accelInG = new Vector3(8, 9, 10);

            DeviceConfiguration.AccelerometerConfiguration config =
                new DeviceConfiguration.AccelerometerConfiguration()
                    {
                       Comment = comment, DeviceId = deviceId, DeviceType = deviceType, Model = model, Pose = pose, 
                    };

            AccelerometerState state = config.Generate(accelInG, nativeDeviceTimestamp);

            Assert.IsNotNull(state);
            Assert.IsTrue(state.DeviceId == deviceId);
            Assert.IsTrue(state.DeviceType == deviceType);
            Assert.IsTrue(state.Model == model);
            Assert.IsTrue(state.Pose.Orientation == pose.Orientation);
            Assert.IsTrue(state.Pose.Position == pose.Position);

            Assert.IsTrue(state.AccelerationInG == accelInG);
        }

        /// <summary>
        /// Tests ability for a DAC.DeviceState to be generate with cached device configuration info
        /// </summary>
        [Priority(0)]
        [TestMethod]
        [TestCategory("Unit")]
        public void TestBattery()
        {
            string comment = "Foo";
            int deviceId = 1;
            DeviceType deviceType = DeviceType.Battery;
            string model = "Faa";
            Vector3 posePosition = new Vector3(1, 2, 3);
            Quaternion poseOrientation = new Quaternion(4, 5, 6, 1.2345);
            Pose pose = new Pose(posePosition, poseOrientation);
            long nativeDeviceTimestamp = 1234;

            double voltage = .1;
            double temperatureInDegreesCelsius = .2;
            double maxVoltage = .3;
            double currentInAmps = .4;
            bool batteryCharging = true;
            double chargePercentage = .5;
            int batteryStatus = 6;

            DeviceConfiguration.BatteryConfiguration config = new DeviceConfiguration.BatteryConfiguration()
                {
                   Comment = comment, DeviceId = deviceId, DeviceType = deviceType, Model = model, Pose = pose, 
                };

            BatteryState state = config.Generate(
                voltage, 
                temperatureInDegreesCelsius, 
                maxVoltage, 
                currentInAmps, 
                batteryCharging,
                chargePercentage, 
                batteryStatus, 
                nativeDeviceTimestamp);

            Assert.IsNotNull(state);
            Assert.IsTrue(state.DeviceId == deviceId);
            Assert.IsTrue(state.DeviceType == deviceType);
            Assert.IsTrue(state.Model == model);
            Assert.IsTrue(state.Pose.Orientation == pose.Orientation);
            Assert.IsTrue(state.Pose.Position == pose.Position);

            Assert.IsTrue(state.BatteryStatus == batteryStatus);
            Assert.IsTrue(state.BatteryCharging == batteryCharging);
            Assert.IsTrue(state.ChargePercentage == chargePercentage);
            Assert.IsTrue(state.CurrentInAmps == currentInAmps);
            Assert.IsTrue(state.MaxVoltage == maxVoltage);
            Assert.IsTrue(state.TemperatureInDegreesCelsius == temperatureInDegreesCelsius);
            Assert.IsTrue(state.Voltage == voltage);
        }

        /// <summary>
        /// Tests ability for a DAC.DeviceState to be generate with cached device configuration info
        /// </summary>
        [Priority(0)]
        [TestMethod]
        [TestCategory("Unit")]
        public void TestButton()
        {
            string comment = "Foo";
            int deviceId = 1;
            DeviceType deviceType = DeviceType.Button;
            string model = "Faa";
            Vector3 posePosition = new Vector3(1, 2, 3);
            Quaternion poseOrientation = new Quaternion(4, 5, 6, 1.2345);
            Pose pose = new Pose(posePosition, poseOrientation);
            long nativeDeviceTimestamp = 1234;

            bool isEngaged = true;

            DeviceConfiguration.ButtonConfiguration config = new DeviceConfiguration.ButtonConfiguration()
                {
                   Comment = comment, DeviceId = deviceId, DeviceType = deviceType, Model = model, Pose = pose, 
                };

            ButtonState state = config.Generate(isEngaged, nativeDeviceTimestamp);

            Assert.IsNotNull(state);
            Assert.IsTrue(state.DeviceId == deviceId);
            Assert.IsTrue(state.DeviceType == deviceType);
            Assert.IsTrue(state.Model == model);
            Assert.IsTrue(state.Pose.Orientation == pose.Orientation);
            Assert.IsTrue(state.Pose.Position == pose.Position);

            Assert.IsTrue(state.IsEngaged == isEngaged);
        }

        /// <summary>
        /// Tests ability for a DAC.DeviceState to be generate with cached device configuration info
        /// </summary>
        [Priority(0)]
        [TestMethod]
        [TestCategory("Unit")]
        public void TestCompass()
        {
            string comment = "Foo";
            int deviceId = 1;
            DeviceType deviceType = DeviceType.Compass;
            string model = "Faa";
            Vector3 posePosition = new Vector3(1, 2, 3);
            Quaternion poseOrientation = new Quaternion(4, 5, 6, 1.2345);
            Pose pose = new Pose(posePosition, poseOrientation);
            long nativeDeviceTimestamp = 1234;

            double compassHeading = .1;
            Vector3 magneticFieldInGauss = new Vector3(9, 10, 11);

            DeviceConfiguration.CompassConfiguration config = new DeviceConfiguration.CompassConfiguration()
                {
                   Comment = comment, DeviceId = deviceId, DeviceType = deviceType, Model = model, Pose = pose, 
                };

            CompassState state = config.Generate(magneticFieldInGauss, compassHeading, nativeDeviceTimestamp);

            Assert.IsNotNull(state);
            Assert.IsTrue(state.DeviceId == deviceId);
            Assert.IsTrue(state.DeviceType == deviceType);
            Assert.IsTrue(state.Model == model);
            Assert.IsTrue(state.Pose.Orientation == pose.Orientation);
            Assert.IsTrue(state.Pose.Position == pose.Position);

            Assert.IsTrue(state.MagneticFieldInGauss == magneticFieldInGauss);
            Assert.IsTrue(state.CompassHeading == compassHeading);
        }

        /// <summary>
        /// Tests ability for a DAC.DeviceState to be generate with cached device configuration info
        /// </summary>
        [Priority(0)]
        [TestMethod]
        [TestCategory("Unit")]
        public void TestDifferentialDrive()
        {
            string comment = "Foo";
            int deviceId = 1;
            DeviceType deviceType = DeviceType.DifferentialDrive;
            string model = "Faa";
            Vector3 posePosition = new Vector3(1, 2, 3);
            Quaternion poseOrientation = new Quaternion(4, 5, 6, 1.2345);
            Pose pose = new Pose(posePosition, poseOrientation);
            long nativeDeviceTimestamp = 1234;

            double rightWheelVelocityInMetersPerSecond = .1;
            double rightWheelPositionInMM = .2;
            double rightWheelAccelerationInMetersPerSecondSquared = .3;
            double leftWheelVelocityInMetersPerSecond = .4;
            double leftWheelPositionInMM = .5;
            double leftWheelAccelerationInMetersPerSecondSquared = .6;
            double wheelBaseInMeters = 0.4;

            DeviceConfiguration.DifferentialDriveConfiguration config =
                new DeviceConfiguration.DifferentialDriveConfiguration()
                    {
                       Comment = comment, DeviceId = deviceId, DeviceType = deviceType, Model = model, Pose = pose, 
                    };

            DifferentialDriveState state = config.Generate(
                rightWheelVelocityInMetersPerSecond, 
                rightWheelPositionInMM, 
                rightWheelAccelerationInMetersPerSecondSquared, 
                leftWheelVelocityInMetersPerSecond, 
                leftWheelPositionInMM, 
                leftWheelAccelerationInMetersPerSecondSquared, 
                nativeDeviceTimestamp,
                wheelBaseInMeters);

            Assert.IsNotNull(state);
            Assert.IsTrue(state.DeviceId == deviceId);
            Assert.IsTrue(state.DeviceType == deviceType);
            Assert.IsTrue(state.Model == model);
            Assert.IsTrue(state.Pose.Orientation == pose.Orientation);
            Assert.IsTrue(state.Pose.Position == pose.Position);

            Assert.IsTrue(
                state.RightWheelAccelerationInMetersPerSecondSquared == rightWheelAccelerationInMetersPerSecondSquared);
            Assert.IsTrue(state.RightWheelPositionInMeters == rightWheelPositionInMM / 1000);
            Assert.IsTrue(state.RightWheelVelocityInMetersPerSecond == rightWheelVelocityInMetersPerSecond);
            Assert.IsTrue(
                state.LeftWheelAccelerationInMetersPerSecondSquared == leftWheelAccelerationInMetersPerSecondSquared);
            Assert.IsTrue(state.LeftWheelPositionInMeters == leftWheelPositionInMM / 1000);
            Assert.IsTrue(state.LeftWheelVelocityInMetersPerSecond == leftWheelVelocityInMetersPerSecond);
        }

        /// <summary>
        /// Tests ability for a DAC.DeviceState to be generate with cached device configuration info
        /// </summary>
        [Priority(0)]
        [TestMethod]
        [TestCategory("Unit")]
        public void TestEncoder()
        {
            string comment = "Foo";
            int deviceId = 1;
            DeviceType deviceType = DeviceType.Encoder;
            string model = "Faa";
            Vector3 posePosition = new Vector3(1, 2, 3);
            Quaternion poseOrientation = new Quaternion(4, 5, 6, 1.2345);
            Pose pose = new Pose(posePosition, poseOrientation);
            long nativeDeviceTimestamp = 1234;

            int countsPerRevolution = 1;
            int count = 2;

            DeviceConfiguration.EncoderConfiguration config = new DeviceConfiguration.EncoderConfiguration()
                {
                   Comment = comment, DeviceId = deviceId, DeviceType = deviceType, Model = model, Pose = pose, 
                };

            EncoderState state = config.Generate(countsPerRevolution, count, nativeDeviceTimestamp);

            Assert.IsNotNull(state);
            Assert.IsTrue(state.DeviceId == deviceId);
            Assert.IsTrue(state.DeviceType == deviceType);
            Assert.IsTrue(state.Model == model);
            Assert.IsTrue(state.Pose.Orientation == pose.Orientation);
            Assert.IsTrue(state.Pose.Position == pose.Position);

            Assert.IsTrue(state.CountsPerRevolution == countsPerRevolution);
            Assert.IsTrue(state.Count == count);
        }

        /// <summary>
        /// Tests ability for a DAC.DeviceState to be generate with cached device configuration info
        /// </summary>
        [Priority(0)]
        [TestMethod]
        [TestCategory("Unit")]
        public void TestFan()
        {
            string comment = "Foo";
            int deviceId = 1;
            DeviceType deviceType = DeviceType.Fan;
            string model = "Faa";
            Vector3 posePosition = new Vector3(1, 2, 3);
            Quaternion poseOrientation = new Quaternion(4, 5, 6, 1.2345);
            Pose pose = new Pose(posePosition, poseOrientation);
            long nativeDeviceTimestamp = 1234;

            double voltageInPercentage = .1;
            int rotationsPerMinute = 2;

            DeviceConfiguration.FanConfiguration config = new DeviceConfiguration.FanConfiguration()
                {
                   Comment = comment, DeviceId = deviceId, DeviceType = deviceType, Model = model, Pose = pose, 
                };

            FanState state = config.Generate(voltageInPercentage, rotationsPerMinute, nativeDeviceTimestamp);

            Assert.IsNotNull(state);
            Assert.IsTrue(state.DeviceId == deviceId);
            Assert.IsTrue(state.DeviceType == deviceType);
            Assert.IsTrue(state.Model == model);
            Assert.IsTrue(state.Pose.Orientation == pose.Orientation);
            Assert.IsTrue(state.Pose.Position == pose.Position);

            Assert.IsTrue(state.VoltageInPercentage == voltageInPercentage);
            Assert.IsTrue(state.RotationsPerMinute == rotationsPerMinute);
        }

        /// <summary>
        /// Tests ability for a DAC.DeviceState to be generate with cached device configuration info
        /// </summary>
        [Priority(0)]
        [TestMethod]
        [TestCategory("Unit")]
        public void TestGyroscope()
        {
            string comment = "Foo";
            int deviceId = 1;
            DeviceType deviceType = DeviceType.Gyroscope;
            string model = "Faa";
            Vector3 posePosition = new Vector3(1, 2, 3);
            Quaternion poseOrientation = new Quaternion(4, 5, 6, 1.2345);
            Pose pose = new Pose(posePosition, poseOrientation);
            long nativeDeviceTimestamp = 1234;

            Vector3 rotationalVelocityInRadiansPerSecond = new Vector3(1, 2, 3);

            DeviceConfiguration.GyroscopeConfiguration config = new DeviceConfiguration.GyroscopeConfiguration()
                {
                   Comment = comment, DeviceId = deviceId, DeviceType = deviceType, Model = model, Pose = pose, 
                };

            GyroscopeState state = config.Generate(rotationalVelocityInRadiansPerSecond, nativeDeviceTimestamp);

            Assert.IsNotNull(state);
            Assert.IsTrue(state.DeviceId == deviceId);
            Assert.IsTrue(state.DeviceType == deviceType);
            Assert.IsTrue(state.Model == model);
            Assert.IsTrue(state.Pose.Orientation == pose.Orientation);
            Assert.IsTrue(state.Pose.Position == pose.Position);

            Assert.IsTrue(state.RotationalVelocityInRadiansPerSecond == rotationalVelocityInRadiansPerSecond);
        }

        /// <summary>
        /// Tests ability for a DAC.DeviceState to be generate with cached device configuration info
        /// </summary>
        [Priority(0)]
        [TestMethod]
        [TestCategory("Unit")]
        public void TestHumidity()
        {
            string comment = "Foo";
            int deviceId = 1;
            DeviceType deviceType = DeviceType.Humidity;
            string model = "Faa";
            Vector3 posePosition = new Vector3(1, 2, 3);
            Quaternion poseOrientation = new Quaternion(4, 5, 6, 1.2345);
            Pose pose = new Pose(posePosition, poseOrientation);
            long nativeDeviceTimestamp = 1234;

            double relativeHumidityInPercentage = .1;

            DeviceConfiguration.HumidityConfiguration config = new DeviceConfiguration.HumidityConfiguration()
                {
                   Comment = comment, DeviceId = deviceId, DeviceType = deviceType, Model = model, Pose = pose, 
                };

            HumidityState state = config.Generate(relativeHumidityInPercentage, nativeDeviceTimestamp);

            Assert.IsNotNull(state);
            Assert.IsTrue(state.DeviceId == deviceId);
            Assert.IsTrue(state.DeviceType == deviceType);
            Assert.IsTrue(state.Model == model);
            Assert.IsTrue(state.Pose.Orientation == pose.Orientation);
            Assert.IsTrue(state.Pose.Position == pose.Position);

            Assert.IsTrue(state.RelativeHumidityInPercentage == relativeHumidityInPercentage);
        }

        /// <summary>
        /// Tests ability for a DAC.DeviceState to be generate with cached device configuration info
        /// </summary>
        [Priority(0)]
        [TestMethod]
        [TestCategory("Unit")]
        public void TestIRProx()
        {
            string comment = "Foo";
            int deviceId = 1;
            DeviceType deviceType = DeviceType.Infrared;
            string model = "Faa";
            Vector3 posePosition = new Vector3(1, 2, 3);
            Quaternion poseOrientation = new Quaternion(4, 5, 6, 1.2345);
            Pose pose = new Pose(posePosition, poseOrientation);
            long nativeDeviceTimestamp = 1234;

            double distanceResolutionInMeters = .1;
            double maximumDistanceInMeters = .2;
            double minimumDistanceInMeters = .3;
            double distanceInMeters = .4;

            DeviceConfiguration.ProximityConfiguration config = new DeviceConfiguration.ProximityConfiguration()
                {
                    Comment = comment, 
                    DeviceId = deviceId, 
                    DeviceType = deviceType, 
                    Model = model, 
                    Pose = pose, 
                    DistanceResolutionInMeters = distanceResolutionInMeters, 
                    MaximumDistanceInMeters = maximumDistanceInMeters, 
                    MinimumDistanceInMeters = minimumDistanceInMeters, 
                };

            IRProximityState state = config.Generate(distanceInMeters, nativeDeviceTimestamp);

            Assert.IsNotNull(state);
            Assert.IsTrue(state.DeviceId == deviceId);
            Assert.IsTrue(state.DeviceType == deviceType);
            Assert.IsTrue(state.Model == model);
            Assert.IsTrue(state.Pose.Orientation == pose.Orientation);
            Assert.IsTrue(state.Pose.Position == pose.Position);

            Assert.IsTrue(state.DistanceInMeters == distanceInMeters);
            Assert.IsTrue(state.DistanceResolutionInMeters == distanceResolutionInMeters);
            Assert.IsTrue(state.MaximumDistanceInMeters == maximumDistanceInMeters);
            Assert.IsTrue(state.MinimumDistanceInMeters == minimumDistanceInMeters);
        }

        /// <summary>
        /// Tests ability for a DAC.DeviceState to be generate with cached device configuration info
        /// </summary>
        [Priority(0)]
        [TestMethod]
        [TestCategory("Unit")]
        public void TestJoint()
        {
            string comment = "Foo";
            int deviceId = 1;
            DeviceType deviceType = DeviceType.Joint;
            string model = "Faa";
            Vector3 posePosition = new Vector3(1, 2, 3);
            Quaternion poseOrientation = new Quaternion(4, 5, 6, 1.2345);
            Pose pose = new Pose(posePosition, poseOrientation);
            long nativeDeviceTimestamp = 1234;

            double positionPrecisionInRadians = .1;
            double positionInRadians = .2;
            double currentVelocityInRadiansPerSecond = .5;
            double currentAccelerationInRadiansPerSecondSquared = .6;

            DeviceConfiguration.JointConfiguration config = new DeviceConfiguration.JointConfiguration()
                {
                   Comment = comment, DeviceId = deviceId, DeviceType = deviceType, Model = model, Pose = pose, 
                };

            JointState state = config.Generate(
                positionPrecisionInRadians, 
                positionInRadians, 
                currentVelocityInRadiansPerSecond, 
                currentAccelerationInRadiansPerSecondSquared, 
                nativeDeviceTimestamp);

            Assert.IsNotNull(state);
            Assert.IsTrue(state.DeviceId == deviceId);
            Assert.IsTrue(state.DeviceType == deviceType);
            Assert.IsTrue(state.Model == model);
            Assert.IsTrue(state.Pose.Orientation == pose.Orientation);
            Assert.IsTrue(state.Pose.Position == pose.Position);

            Assert.IsTrue(
                state.CurrentAccelerationInRadiansPerSecondSquared == currentAccelerationInRadiansPerSecondSquared);
            Assert.IsTrue(state.CurrentVelocityInRadiansPerSecond == currentVelocityInRadiansPerSecond);
            Assert.IsTrue(state.PositionPrecisionInRadians == positionPrecisionInRadians);
            Assert.IsTrue(state.PositionInRadians == positionInRadians);
        }

        /// <summary>
        /// Tests ability for a DAC.DeviceState to be generate with cached device configuration info
        /// </summary>
        [Priority(0)]
        [TestMethod]
        [TestCategory("Unit")]
        public void TestPower()
        {
            string comment = "Foo";
            int deviceId = 1;
            DeviceType deviceType = DeviceType.Power;
            string model = "Faa";
            Vector3 posePosition = new Vector3(1, 2, 3);
            Quaternion poseOrientation = new Quaternion(4, 5, 6, 1.2345);
            Pose pose = new Pose(posePosition, poseOrientation);
            long nativeDeviceTimestamp = 1234;

            int powerState = 1;

            DeviceConfiguration.PowerConfiguration config = new DeviceConfiguration.PowerConfiguration()
                {
                   Comment = comment, DeviceId = deviceId, DeviceType = deviceType, Model = model, Pose = pose, 
                };

            PowerState state = config.Generate(powerState, nativeDeviceTimestamp);

            Assert.IsNotNull(state);
            Assert.IsTrue(state.DeviceId == deviceId);
            Assert.IsTrue(state.DeviceType == deviceType);
            Assert.IsTrue(state.Model == model);
            Assert.IsTrue(state.Pose.Orientation == pose.Orientation);
            Assert.IsTrue(state.Pose.Position == pose.Position);

            Assert.IsTrue(state.State == powerState);
        }

        /// <summary>
        /// Tests ability for a DAC.DeviceState to be generate with cached device configuration info
        /// </summary>
        [Priority(0)]
        [TestMethod]
        [TestCategory("Unit")]
        public void TestProjector()
        {
            string comment = "Foo";
            int deviceId = 1;
            DeviceType deviceType = DeviceType.Projector;
            string model = "Faa";
            Vector3 posePosition = new Vector3(1, 2, 3);
            Quaternion poseOrientation = new Quaternion(4, 5, 6, 1.2345);
            Pose pose = new Pose(posePosition, poseOrientation);
            long nativeDeviceTimestamp = 1234;

            bool verticalInversion = true;
            bool horizontialInversion = true;
            short focalLengthOffset = 1;
            short brightness = 2;

            DeviceConfiguration.ProjectorConfiguration config = new DeviceConfiguration.ProjectorConfiguration()
                {
                   Comment = comment, DeviceId = deviceId, DeviceType = deviceType, Model = model, Pose = pose, 
                };

            ProjectorState state = config.Generate(
                verticalInversion, horizontialInversion, focalLengthOffset, brightness, nativeDeviceTimestamp);

            Assert.IsNotNull(state);
            Assert.IsTrue(state.DeviceId == deviceId);
            Assert.IsTrue(state.DeviceType == deviceType);
            Assert.IsTrue(state.Model == model);
            Assert.IsTrue(state.Pose.Orientation == pose.Orientation);
            Assert.IsTrue(state.Pose.Position == pose.Position);

            Assert.IsTrue(state.VerticalInversion == verticalInversion);
            Assert.IsTrue(state.HorizontialInversion == horizontialInversion);
            Assert.IsTrue(state.FocalLengthOffset == focalLengthOffset);
            Assert.IsTrue(state.Brightness == brightness);
        }

        /// <summary>
        /// Tests ability for a DAC.DeviceState to be generate with cached device configuration info
        /// </summary>
        [Priority(0)]
        [TestMethod]
        [TestCategory("Unit")]
        public void TestSonar()
        {
            string comment = "Foo";
            int deviceId = 1;
            DeviceType deviceType = DeviceType.Sonar;
            string model = "Faa";
            Vector3 posePosition = new Vector3(1, 2, 3);
            Quaternion poseOrientation = new Quaternion(4, 5, 6, 1.2345);
            Pose pose = new Pose(posePosition, poseOrientation);
            long nativeDeviceTimestamp = 1234;

            double distancePrecisionInMeters = .1;
            double maximumDistanceInMeters = .2;
            double minimumDistanceInMeters = .3;
            double distanceInMeters = .4;

            DeviceConfiguration.SonarConfiguration config = new DeviceConfiguration.SonarConfiguration()
                {
                    Comment = comment, 
                    DeviceId = deviceId, 
                    DeviceType = deviceType, 
                    Model = model, 
                    Pose = pose, 
                    DistancePrecisionInMeters = distancePrecisionInMeters, 
                    MaximumDistanceInMeters = maximumDistanceInMeters, 
                    MinimumDistanceInMeters = minimumDistanceInMeters, 
                };

            SonarState state = config.Generate(distanceInMeters, nativeDeviceTimestamp);

            Assert.IsNotNull(state);
            Assert.IsTrue(state.DeviceId == deviceId);
            Assert.IsTrue(state.DeviceType == deviceType);
            Assert.IsTrue(state.Model == model);
            Assert.IsTrue(state.Pose.Orientation == pose.Orientation);
            Assert.IsTrue(state.Pose.Position == pose.Position);

            Assert.IsTrue(state.DistanceInMeters == distanceInMeters);
            Assert.IsTrue(state.DistancePrecisionInMeters == distancePrecisionInMeters);
            Assert.IsTrue(state.MaximumDistanceInMeters == maximumDistanceInMeters);
            Assert.IsTrue(state.MinimumDistanceInMeters == minimumDistanceInMeters);
        }

        /// <summary>
        /// Tests ability for a DAC.DeviceState to be generate with cached device configuration info
        /// </summary>
        [Priority(0)]
        [TestMethod]
        [TestCategory("Unit")]
        public void TestTemperature()
        {
            string comment = "Foo";
            int deviceId = 1;
            DeviceType deviceType = DeviceType.Temperature;
            string model = "Faa";
            Vector3 posePosition = new Vector3(1, 2, 3);
            Quaternion poseOrientation = new Quaternion(4, 5, 6, 1.2345);
            Pose pose = new Pose(posePosition, poseOrientation);
            long nativeDeviceTimestamp = 1234;

            double temperatureInDegreesCelsius = 37.5;

            DeviceConfiguration.TemperatureConfiguration config = new DeviceConfiguration.TemperatureConfiguration()
                {
                   Comment = comment, DeviceId = deviceId, DeviceType = deviceType, Model = model, Pose = pose, 
                };

            TemperatureState state = config.Generate(temperatureInDegreesCelsius, nativeDeviceTimestamp);

            Assert.IsNotNull(state);
            Assert.IsTrue(state.DeviceId == deviceId);
            Assert.IsTrue(state.DeviceType == deviceType);
            Assert.IsTrue(state.Model == model);
            Assert.IsTrue(state.Pose.Orientation == pose.Orientation);
            Assert.IsTrue(state.Pose.Position == pose.Position);

            Assert.IsTrue(state.TemperatureInDegreesCelsius == temperatureInDegreesCelsius);
        }
    }
}
